'''两点交叉'''
def swithstr(x1,x2):
    w1 = random.uniform(0.6, 0.8)
    w2 = 1 - w1
    for i in range(x_dim):
        temp = w1*x1[i]+w2*x2[i]
        x2[i] = w1 * x2[i] + w2 * x1[i]
        x1[i] = temp
        #范围检查
        x1[i] = check_border(x1[i])
        x2[i] = check_border(x2[i])
    return x1,x2

'''三点交叉'''
def swithstr2(x1,x2,x3):
    for i in range(x_dim):
        mean = (x1[i]+x2[i]+x3[i])/3
        x1[i] = (1 + 0.01)*(x1[i]-mean)
        x2[i] = (1 + 0.01) * (x2[i] - mean)
        x3[i] = (1 + 0.01) * (x3[i] - mean)
        #范围检查
        x1[i] = check_border(x1[i])
        x2[i] = check_border(x2[i])
        x3[i] = check_border(x3[i])
    return x1,x2